import {
  mapGetters
} from 'vuex'
export default {
  computed: {
    ...mapGetters('m_cart', ['total']),
  },
  onShow() {
    this.setTabbarBadge()
  },
  watch: {
    total() {
      return this.setTabbarBadge()
    }
  },
  methods: {
    setTabbarBadge() {
      if (this.total === 0) {
        uni.removeTabBarBadge({
          index: 2
        })
      } else {
        uni.setTabBarBadge({
          index: 2,
          text: this.total + ''
        })
      }
    },
  },
}
